import React from 'react';

const Radio = React.createClass({
  handleChange(e) {
    const data = {};
    data.target = e.target || e.srcElement;
    data.value = this.props['data-value'];
    data.name = this.props['data-target'];
    if (this.props.onClick) {
      this.props.onClick(data);
    }
  },
  render() {
    const props = this.props;
    return (
      <div className="radio-block">
        <span className="radio-inner">
          {props.defaultChecked ? <span className="radio-inner1"></span> : ''}
        </span>
        <input
          type="radio"
          name={props.name}
          data-value={props['data-value']}
          onClick={this.handleChange}
          // checked={props.checked}
          defaultChecked={props.defaultChecked}
        />
      </div>
    );
  }
});

export default Radio;
